package Polymorphism;

public class Laptop {
    public void start(){
        System.out.println("笔记本,启动!");
    }
    public void close(){
        System.out.println("笔记本, 关闭!");
    }
    public void useUSB(USB usb){
        if (usb instanceof Mouse){
//            向下转型  可以调用子类特有方法
            Mouse mouse = (Mouse) usb;
            mouse.open();
            mouse.click();
            mouse.close();
        }
        if (usb instanceof Keyboard){
            Keyboard keyboard = (Keyboard) usb;
            keyboard.open();
            keyboard.type();
            keyboard.close();
        }
    }
}
